import $mUtils from '@/common/utils'

export default {
	/*
		router:跳转的路由,
		params:跳转的需要携带的参数,
	*/
	navigateToIdx(router: any, params: any) {
		if (router == 0 || router == undefined || router === null) {
			return
		}
		if (router.route) {
			for (let i in params) {
				if (params[i] === null || params[i] == undefined) {
					delete params[i]
				}
			}
			if (router.route.includes('pages/index')) {
				if (getCurrentPages()[0].route != router.route) {
					$mUtils.pushTab({
						path: `/${router.route}`,
						query: {
							...params
						}
					})
				}
			} else {
				$mUtils.push({
					path: `/${router.route}`,
					query: {
						...params
					}
				})
			}
		} else {
			$mUtils.pushTab({
				path: '/pages/index/index'
			})
		}
	}
}
